package com.lucfzy.configurer;

import com.lucfzy.interceptor.CorsInterceptor;
import com.lucfzy.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebAppConfigurer extends WebMvcConfigurationSupport {

    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Autowired
    private CorsInterceptor corsInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(corsInterceptor).addPathPatterns("/**");
        // token拦截器
        registry.addInterceptor(tokenInterceptor).excludePathPatterns("/login/**", "/register/**", "/updatePass/**");
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/query");
    }

}
